export default {
  namespaced: true,
  state: () => {
    return {
      token: uni.getStorageSync('token') || '',
      userinfo: uni.getStorageSync('userinfo') || {},
    }
  },
  mutations: {
    // 设置用户信息
    setUserInfo(state, userinfo) {
      state.userinfo = userinfo
      // 持久化存储
      uni.setStorageSync('userinfo', state.userinfo)
    },
    setAvartUrl(state,avatarUrl){
       state.userinfo.avatarUrl=avatarUrl
       console.log(state.userinfo)
       // 持久化存储
       uni.setStorageSync('userinfo', state.userinfo)
    },
    setNickName(state,nickName){
       state.userinfo.nickName=nickName
       // 持久化存储
       uni.setStorageSync('userinfo', state.userinfo)
    },
    setToken(state, token) {
      state.token = token
      // 持久化存储
      uni.setStorageSync('token', state.token)
    }
  }
}
